package com.techstar.ats.netty.handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import com.techstar.ats.codec.history.encoder.F18AlarmAskEncoder;
import com.techstar.ats.codec.history.encoder.F21LoadHistoryTgDataEncoder;
import com.techstar.ats.codec.live.codec.F01MessagePollingCodec;
import com.techstar.ats.codec.live.encoder.F03LoadDeviceStatusEncoder;
import com.techstar.ats.codec.live.encoder.F12ReportAskEncoder;
import com.techstar.ats.codec.resume.encoder.F24ResumeAskEncoder;
import com.techstar.ats.dxp.AtsRequest;
import com.techstar.ats.dxp.history.req.F12ReportAsk;
import com.techstar.ats.dxp.history.req.F18AlarmAsk;
import com.techstar.ats.dxp.history.req.F21LoadHistoryTgData;
import com.techstar.ats.dxp.live.req.F01MessagePolling;
import com.techstar.ats.dxp.live.req.F03LoadDeviceStatus;
import com.techstar.ats.dxp.resume.req.F24ResumeAsk;

public class AtsRequestEncoder extends MessageToByteEncoder<AtsRequest> {

	@Override
	protected void encode(ChannelHandlerContext ctx, AtsRequest msg, ByteBuf out) {
		if(msg instanceof F01MessagePolling) {
			F01MessagePollingCodec.INSTANCE.encode(out, (F01MessagePolling) msg);
		} else if(msg instanceof F03LoadDeviceStatus) {
			F03LoadDeviceStatusEncoder.INSTANCE.encode(out, (F03LoadDeviceStatus) msg);
		} else if(msg instanceof F12ReportAsk) {
			F12ReportAskEncoder.INSTANCE.encode(out, (F12ReportAsk) msg);
		} else if(msg instanceof F18AlarmAsk) {
			F18AlarmAskEncoder.INSTANCE.encode(out, (F18AlarmAsk) msg);
		} else if(msg instanceof F21LoadHistoryTgData) {
			F21LoadHistoryTgDataEncoder.INSTANCE.encode(out, (F21LoadHistoryTgData) msg);
		} else if(msg instanceof F24ResumeAsk) {
			F24ResumeAskEncoder.INSTANCE.encode(out, (F24ResumeAsk) msg);
		}
	}
}
